package com.example.rmiclientdemo.client;

import com.example.rmicommondemo.service.iface.RmiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.naming.Context;

@Slf4j
@Component
public class RmiClient {

    @Autowired
    private Context context;

    public String run() throws Exception {
        RmiService service = (RmiService) context.lookup("hello");
        // 可能抛出RemoteException的RMI调用
        return service.sayHello();

    }

    public void run1() throws Exception {
        Object hello1 = context.lookup("hello1");
        log.info("hello1:"+hello1);
    }
}